/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-17
 */

class Animal {
    public String name;
    public int age;
    public void eat() {
        System.out.println(name + "吃饭");
    }
}

class Dog extends Animal {
    public void action() {
        System.out.println(name + "摇尾巴");
    }
    public void eat() {
        System.out.println(name + "吃狗粮");
    }
}

class Cat extends Animal {
    public void action() {
        System.out.println(name + "抓老鼠");
    }
    @Override
    public void eat() {
        System.out.println(name + "吃猫粮");
    }
}
public class Main {
    public static void func(Animal a) {
        a.eat();
    }
    public static void main(String[] args) {
        Animal dog = new Dog();
        Animal cat = new Cat();
        Animal animal = new Animal();
        func(new Dog());
        func(new Cat());
        if (dog instanceof Dog){
            Dog dog1 = (Dog)dog;
            dog1.name = "张三";
            dog1.eat();
        }
    }

}
